package org.domain.demo.session.query;

import org.domain.demo.entity.Users;
import org.jboss.seam.annotations.Name;
import org.jboss.seam.framework.EntityQuery;
import java.util.Arrays;

@Name("usersQuery")
public class UsersQuery extends EntityQuery<Users>
{

    private static final String EJBQL = "select users from Users users";

    private static final String[] RESTRICTIONS = {
        "lower(users.principal) like lower(concat(#{usersQuery.users.principal},'%'))",
        "lower(users.firstName) like lower(concat(#{usersQuery.users.firstName},'%'))",
        "lower(users.lastName) like lower(concat(#{usersQuery.users.lastName},'%'))",
        "lower(users.password) like lower(concat(#{usersQuery.users.password},'%'))",
    };

    private Users users = new Users();

    public UsersQuery()
    {
        setEjbql(EJBQL);
        setRestrictionExpressionStrings(Arrays.asList(RESTRICTIONS));
    }

    public Users getUsers()
    {
        return users;
    }
}
